;(function($) {
    $.fn.unveil = function(threshold, callback) {
        var $w = $(window), th = threshold || 0, retina = window.devicePixelRatio > 1, attrib = retina ? "data-src-retina" : "data-src", images = this, loaded;
        this.one("unveil", function() {
            var source = this.getAttribute(attrib);
            source = source || this.getAttribute("data-src");
            if (source) {
                this.setAttribute("src", source);
                if (typeof callback === "function")
                    callback.call(this);
            }
        });
        function unveil() {
            var inview = images.filter(function() {
                var $e = $(this);
                if ($e.is(":hidden"))
                    return;
                var wt = $w.scrollTop()
                  , wb = wt + $w.height()
                  , et = $e.offset().top
                  , eb = et + $e.height();
                return eb >= wt - th && et <= wb + th;
            });
            loaded = inview.trigger("unveil");
            images = images.not(loaded);
        }
        $w.on("scroll.unveil resize.unveil lookup.unveil", unveil);
        unveil();
        return this;
    }
    ;
})(window.jQuery || window.Zepto);
jQuery(function($) {
    $(document).ready(function() {
        $('figure img').unveil();
		// footer weixin
    
	$('#social-weixin').hover(function() {
        $('.weixinimg').stop().show(300);
    }, function() {
        $('.weixinimg').stop().hide(300);
    });
    })
    $('#offcanvas-toggler').on('click', function(event) {
        event.preventDefault();
        $('body').addClass('offcanvas');
    });
    $('.close-offcanvas, .offcanvas-overlay').on('click', function(event) {
        event.preventDefault();
        $('body').removeClass('offcanvas');
    });
    $('.sp-megamenu-wrapper').parent().parent().css('position', 'static').parent().css('position', 'relative');
    $('.sp-menu-full').each(function() {
        $(this).parent().addClass('menu-justify');
    });
    $('[data-toggle="tooltip"]').tooltip();
    $(document).on('click', '.sp-rating .star', function(event) {
        event.preventDefault();
        var data = {
            'action': 'voting',
            'user_rating': $(this).data('number'),
            'id': $(this).closest('.post_rating').attr('id')
        };
        var request = {
            'option': 'com_ajax',
            'plugin': 'helix3',
            'data': data,
            'format': 'json'
        };
        $.ajax({
            type: 'POST',
            data: request,
            beforeSend: function() {
                $('.post_rating .ajax-loader').show();
            },
            success: function(response) {
                var data = $.parseJSON(response.data);
                $('.post_rating .ajax-loader').hide();
                if (data.status == 'invalid') {
                    $('.post_rating .voting-result').text('You have already rated this entry!').fadeIn('fast');
                } else if (data.status == 'false') {
                    $('.post_rating .voting-result').text('Somethings wrong here, try again!').fadeIn('fast');
                } else if (data.status == 'true') {
                    var rate = data.action;
                    $('.voting-symbol').find('.star').each(function(i) {
                        if (i < rate) {
                            $(".star").eq(-(i + 1)).addClass('active');
                        }
                    });
                    $('.post_rating .voting-result').text('Thank You!').fadeIn('fast');
                }
            },
            error: function() {
                $('.post_rating .ajax-loader').hide();
                $('.post_rating .voting-result').text('Failed to rate, try again!').fadeIn('fast');
            }
        });
    });
    $(document).ready(function() {
        $('body.layout-blog #sp-right, body.view-article #sp-right,body.view-category #sp-right, #forum-sidebar').theiaStickySidebar({
            additionalMarginTop: 100
        });
    });
    $('#select-question').on('change', function(event) {
        if ($(this).val() == 'Others') {
            $('#input-subject').attr('required', '').parent().show();
        } else {
            $('#input-subject').removeAttr('required', '').parent().hide();
        }
    });
    $(document).on('submit', '.sppb-ajaxt-contact-form-advanced', function(event) {
        var $this = $(this);
        event.preventDefault();
        var $self = $(this);
		var name = $('#name').val();
		var tel = $('#tel').val();
        var email = $('#email').val();
		var message = $('#message').val();
		var request = 'name='+ name + '&tel=' + tel + '&email=' + email + '&message='+ message +'&action=post'+ '&diyid=1&do=2&dede_fields=name,text;tel,text;email,text;message,multitext&dede_fieldshash=8a1291725739b932f59a4ff2e21ffb6d';
        $.ajax({
            type: 'POST',
			url: "/plus/diy.php",
            data: request,
            beforeSend: function() {
                $self.find('.fa').addClass('fa-spinner fa-spin');
            },
            success: function(data) {
                
                $self.find('.fa-spin').removeClass('fa-spinner fa-spin');
                if (data) {
                    $this.find('input[type=text], input[type=email], input[type=number], textarea').val("");
                }
                $self.next('.sppb-ajax-contact-status').html(data).fadeIn().delay(5000).fadeOut(500);
                
            }
        });
        return false;
    });

//quanjukefu
    var viewportHeight;
    var viewportWidth;
    if (document.compatMode === 'BackCompat') {
        viewportHeight = document.body.clientHeight;
        viewportWidth = document.body.clientWidth;
    } else {
        viewportHeight = document.documentElement.clientHeight;
        viewportWidth = document.documentElement.clientWidth;
    }
    $(window).on('scroll',function(){
        score();
    });
    function score(){
        var scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
        if(scrollTop > 300){
            showScrollTop();
        }else{
            hideScrollTop();
        }
    }
    score();
    function showScrollTop(){
        if($('.Global_ScrollToTop')){
            $('.Global_ScrollToTop').remove();
        }
        var $scrollToTop = $('<div class="Global_ScrollToTop"></div>');
        $('body').append($scrollToTop);
        $scrollToTop.on('click',function(){
            $('html, body').animate({scrollTop: 0}, 300);
        });
    }
    function hideScrollTop(){
        if($('.Global_ScrollToTop')){
            $('.Global_ScrollToTop').remove();
        }
    }
	$('.servers_btn').on('click', function(event) {
        event.preventDefault();
        $('.Global_HEADER_servers').addClass('show');
    });
	$('.closeBtn').on('click', function(event) {
        event.preventDefault();
        $('.Global_HEADER_servers').removeClass('show');
    });
//quanjukefu end
  
});
/*jinzhi
var lockAdminObj = {"aivelockCopy":"1","aivelockRightmouse":"1","aivelockDebug":"1","aivelockControladv":"","aivelockPopupadv":""};
try {
    !(function($) {
        "use strict";
        $.aivelock = function(options) {
            this.options = this.opts(options);
            this.isCommand = false;
            var self = this;
            $(this.options.target).on('keydown', function(e) {
                var key = e.charCode || e.keyCode;
                console.log(key);
                if (self.options.lock.debug && key == 123) {
                    e.preventDefault();
                    self.popupHandle();
                }
                self.disableCtrlKeyCombination(e);
            })
            $(this.options.target).on('keyup', function(e) {
                var key = e.charCode || e.keyCode;
                if (self.isCommand == true && key == 224)
                    self.isCommand = false;
            })
            if (self.options.lock.copy == true)
                self.lockCopy();
            if (self.options.lock.rightMouse == true)
                self.rightMouse();
        }
        ;
        $.aivelock.prototype.lockDebug = function(ev) {
            ev.preventDefault();
            this.popupHandle();
        }
        $.aivelock.prototype.disableCtrlKeyCombination = function(e) {
            var key = ''
              , isCtrl = ''
              , key = e.charCode || e.keyCode;
            if (this.isCommand == true && key == 85) {
                e.preventDefault();
                this.popupHandle();
            }
            if (this.isCommand == true && key == 74) {
                e.preventDefault();
                this.popupHandle();
            }
            if (window.event) {
                if (window.event.ctrlKey)
                    isCtrl = true;
                else
                    isCtrl = false;
            } else {
                if (e.ctrlKey)
                    isCtrl = true;
                else
                    isCtrl = false;
            }
            if (key == 224)
                this.isCommand = true;
            if (isCtrl) {
                e.preventDefault();
                this.popupHandle();
            }
            return true;
        }
        $.aivelock.prototype.lockCopy = function() {
            var self = this;
            $(this.options.target).on('cut copy', function(e) {
                e.preventDefault();
                self.popupHandle();
            });
        }
        $.aivelock.prototype.rightMouse = function() {
            var self = this;
            $(this.options.target).on('contextmenu', function(e) {
                e.preventDefault();
                self.popupHandle();
            });
        }
        $.aivelock.prototype.popupHandle = function() {
            if (this.options.popup.openWhenLock != true)
                return;
            $('.ll-popup-wrap').remove();
            this.popup = $('<div>', {
                class: 'll-popup-wrap',
                html: '<div class="ll-popup-inner"><div class="ll-popup-body">' + this.options.popup.content + '</div></div>'
            })
            var self = this;
            $('html').on('click', function(e) {
                if ($(e.target).hasClass('ll-popup-wrap'))
                    self.popup.remove();
            })
            $('html').append(this.popup);
            this.popupBody = this.popup.find('.ll-popup-body');
            dynamics.css(this.popupBody[0], {
                translateY: 200
            })
            dynamics.animate(this.popupBody[0], {
                translateY: 0
            }, {
                type: dynamics.spring,
                duration: 908,
                frequency: 516,
                friction: 341,
                anticipationStrength: 129
            })
        }
        $.aivelock.prototype.opts = function(options) {
            return $.extend({
                target: 'html',
                popup: {
                    openWhenLock: false,
                    content: '',
                },
                lock: {
                    copy: true,
                    rightMouse: true,
                    debug: true,
                }
            }, options);
        }
    })(jQuery);
} catch (e) {}
try {
    !(function($) {
        $(function() {
            var opts = {
                target: 'html',
                popup: {
                    openWhenLock: lockAdminObj.aivelockControladv,
                    content: lockAdminObj.aivelockPopupadv,
                },
                lock: {
                    copy: lockAdminObj.aivelockCopy,
                    rightMouse: lockAdminObj.aivelockRightmouse,
                    debug: lockAdminObj.aivelockDebug,
                }
            };
            new $.aivelock(opts)
        })
    })(jQuery);
} catch (e) {}*/